/*
* @Description: store
* @Verson: v1.0
* @Author: xvyy
* @Date: 2024-11-29 15:28
*/
import {defineStore} from "pinia";

let definePerson =
    defineStore("personPinia", {
        /*defineStore({
        //必须唯一
        id: 'personPinia',*/ //过时
        //声明数据
        state: () => {
            return {
                username: 'zgxx',
                age: '21',
                hobbies: ['唱', '跳', 'rap', '篮球']
            }
        },
        //声明属性  属性是需要计算的
        getters: {

            /*        getHobbiesCount:function(){
                        return this.hobbies.length
                    }, 省略 :function
                    */
            getHobbiesCount() {
                return this.hobbies.length
            },
            getAge() {
                return this.age
            }
        },
        //声明方法  方法是需要执行的
        actions: {
            doubleAge() {
                this.age *= 2;
            },
        }
    })

export default definePerson;